﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BlogDH.User
{
    public class BasePage : System.Web.UI.Page
    {
        private int userID;
        private string userName;
        private Model.UserInfo _userinfo;




        protected override void OnInit(EventArgs e)
        {
            int.TryParse(CommMethod.GetCookieValue("t"), out userID);
            this.userName = CommMethod.GetCookieValue("u");
            if (string.IsNullOrEmpty(UserName) || UserID == 0)
            {
                Response.Write("<script>window.location.href='/login.aspx'</script>");
                Response.End();
            }
        }



        public Model.UserInfo userinfo2
        {
            get
            {
                if (_userinfo == null)
                    _userinfo = new BLL.UserInfo().GetModel(UserID, UserName);

                if (_userinfo == null)
                {
                    Response.Write("<script>window.location.href='/login.aspx'</script>");
                    Response.End();
                }
                return _userinfo;
            }
        }

        public string UserName
        {
            get { return userName; }
        }

        public int UserID
        {
            get { return userID; }
        }
    }
}